package com.aner.test.controller;
import com.aner.tester.controller.BaseControllerTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.aner.tester.utils.text.StringUtils;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;


/**
 * RequestTestControllerTest class
 * 
 * @author aner
 * @date 2020-12-30
 */
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@RunWith(SpringRunner.class)
@AutoConfigureMockMvc
public class RequestTestControllerTest extends BaseControllerTest
{

    @Test
    public void testTest() {
        String params = "{'booleanTest':false,'byteTest':1,'dateTest':'2020-12-30 13:39:02','doubleTest':0.9260944957365136,'floatTest':0.50662374,'intTest':0,'longTest':3,'stringTest':'故猫'}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.request("/test/", jsonStr);
        
    }
    @Test
    public void testRequestParamDateTest() {
        String params = "{'testDate':'2020-12-30 13:39:02'}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.request("/testRequestParamDate/", jsonStr);
        
    }
    @Test
    public void testRequestBodyDateTest() {
        String params = "1609306742207";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.requestBody("/testRequestBodyDate/", jsonStr);
        
    }
    @Test
    public void testRequestBodyListTest() {
        String params = "['猪事00','40小5狗公','0广','的小猫小']";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.requestBody("/testRequestBodyList/", jsonStr);
        
    }
    @Test
    public void testRequestParamListTest() {
        String params = "{'testList':['5小公第','狗司小省']}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.request("/testRequestParamList/", jsonStr);
        
    }
    @Test
    public void testRequestBodyMapTest() {
        String params = "{'猫的':'58589','三个狗':'015405'}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.requestBody("/testRequestBodyMap/", jsonStr);
        
    }
    @Test
    public void testRequestBodyLongTest() {
        String params = "1";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.requestBody("/testRequestBodyLong/", jsonStr);
        
    }
    @Test
    public void testPathVariableTest() {
        String params = "{'params':['第广第广三','广4个猫','个4','小个小省四','故东告'],'id':[1,0,2,0,0]}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.request("/testPathVariable/{params}/{id}", jsonStr);
        
    }
    @Test
    public void testDateTest() {
        String params = "{'test':'2020-12-30 13:39:02'}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.request("/testDate/", jsonStr);
        
    }
    @Test
    public void testBodyTest() {
        String params = "{'booleanTest':false,'byteTest':0,'dateTest':'2020-12-30 13:39:02','doubleTest':0.04345544947408897,'floatTest':0.3078807,'intTest':0,'longTest':0,'strArray':['省省','猫安事告'],'stringList':['事小','猪司省个'],'stringTest':'司5告告','testObjectArray':[{'booleanTest':true,'byteTest':0,'dateTest':'2020-12-30 13:39:02','doubleTest':0.18722250441045052,'floatTest':0.76176775,'intTest':0,'longTest':3,'stringTest':'广东'},{'booleanTest':false,'byteTest':1,'dateTest':'2020-12-30 13:39:02','doubleTest':0.5736554521780564,'floatTest':0.6012904,'intTest':1,'longTest':0,'stringTest':'小告2广4故'},{'booleanTest':false,'byteTest':1,'dateTest':'2020-12-30 13:39:02','doubleTest':0.7064405385311602,'floatTest':0.42070478,'intTest':0,'longTest':0,'stringTest':'三猪四省的广'}],'testObjectList':[{'booleanTest':false,'byteTest':1,'dateTest':'2020-12-30 13:39:02','doubleTest':0.7085572612200874,'floatTest':0.39196187,'intTest':1,'longTest':0,'stringTest':'小告三狗尔'},{'booleanTest':true,'byteTest':0,'dateTest':'2020-12-30 13:39:02','doubleTest':0.9735841663934103,'floatTest':0.8524916,'intTest':1,'longTest':1,'stringTest':'猫小告狗1'},{'booleanTest':false,'byteTest':1,'dateTest':'2020-12-30 13:39:02','doubleTest':0.13733919068009326,'floatTest':0.49055785,'intTest':1,'longTest':2,'stringTest':'的的'},{'booleanTest':false,'byteTest':0,'dateTest':'2020-12-30 13:39:02','doubleTest':0.7969222799067847,'floatTest':0.5037704,'intTest':0,'longTest':0,'stringTest':'省司省'},{'booleanTest':false,'byteTest':0,'dateTest':'2020-12-30 13:39:02','doubleTest':0.21412055786347728,'floatTest':0.42469418,'intTest':1,'longTest':0,'stringTest':'猫狗'},{'booleanTest':true,'byteTest':1,'dateTest':'2020-12-30 13:39:02','doubleTest':0.31108953339161494,'floatTest':0.27467126,'intTest':1,'longTest':1,'stringTest':'0猫0'}],'testObjectMap':{'尔猫的司':'34','小小省故':'83','公的5猪':'594','个34':'685350','的尔':'3591'}}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.requestBody("/testRequestBody/", jsonStr);
        
    }
}
